﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace yichu_front
{
    public partial class Form_BOMListPriceHistoryManage : Form
    {
        public Form_BOMListPriceHistoryManage()
        {
            InitializeComponent();
        }

        private void Form_BOMListPriceHistoryManage_Load(object sender, EventArgs e)
        {
            getAllBomListHistory();
        }
        private void getAllBomListHistory()
        {
            DataTable dt = SqlSugarHelp.scope.Ado.GetDataTable("select distinct ''序号, [修改时间],[备注] from [BOMListPriceHistory] order by [修改时间]");
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dt.Rows[i]["序号"] = i + 1;
                }
            }
            this.dataGridView1.DataSource = dt;
        }

        private void buttonQuer_Click(object sender, EventArgs e)
        {
            DataTable dt = SqlSugarHelp.scope.Ado
                        .GetDataTable("select distinct ''序号, 修改时间,备注 from BOMListPriceHistory  where 修改时间 >= @from and 修改时间 <= @to order by 修改时间", new { from = this.dateTimePickerFrom.Value, to = this.dateTimePickerTo.Value });
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dt.Rows[i]["序号"] = i + 1;
                }
            }
            this.dataGridView1.DataSource = dt;
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                string 修改时间 = dataGridView1.Rows[e.RowIndex].Cells["C存档时间"].Value.ToString();
                string 备注 = dataGridView1.Rows[e.RowIndex].Cells["C备注"].Value.ToString();
                FormBOMListPriceHistoryV2 formBOMListPriceHistoryV2 = new FormBOMListPriceHistoryV2(修改时间, 备注);
                formBOMListPriceHistoryV2.ShowDialog();
            }
        }
    }
}
